<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/4/10 0010
 * Time: 15:06
 */

namespace App\Service;

use Hyperf\Di\Annotation\Inject;
use App\Model\User;

/**
 * Class UserService
 * @package App\Service
 */

class UserService
{

    /**
     * @Inject()
     * @var User
     */
    private $user;

    /**
     * 获取单条数据
     * @param int $id
     * @return \App\Model\BaseModel|\Hyperf\Database\Model\Model|null
     */
    public function getOne(int $id)
    {
        return $this->user->getOne($id);
    }


    /**
     * 协程获取列表
     * @param array $map
     * @return array
     */
    public function getUserList(array $map)
    {
        return $this->user->parallelSearch([], $map, ['*']);
    }

    /**
     * 新增
     * @param array $map
     * @return bool
     */
    public function add(array $map)
    {
        return $this->user->saveModel($map);
    }


    public function update($orm, $map)
    {
        return $this->user->updateModel($orm, $map);
    }
}